package sketch.labels.jtrees;

import java.awt.Component;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

import sketch.labels.nodes.Node;

public class MyTreeCellRenderer extends DefaultTreeCellRenderer {

	@Override
	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean selected, boolean expanded, boolean leaf, int row,
			boolean hasFocus) {
		super.getTreeCellRendererComponent(tree, value, selected, expanded,leaf, row, hasFocus);
		DefaultMutableTreeNode n = (DefaultMutableTreeNode) value;
		if (!n.isRoot()) {
			Node node = (Node) ((DefaultMutableTreeNode) value).getUserObject();
			setForeground(node.getColor());
		}
		return this;
	}

}
